﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using KL.Store.Core;

namespace KL.Store.Web
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            //var productUrlFolderStr = "";
            //if (!string.IsNullOrEmpty(Parameters.ProductUrlFolderName))
            //{
            //    productUrlFolderStr = Parameters.ProductUrlFolderName + "/";
            //}

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{file}.xml");
            routes.IgnoreRoute("{file}.xls");

            routes.MapRoute(
                name: "Robots",
                url: "robots.txt",
                defaults: new { controller = "Home", action = "Robots" }
            );

            routes.MapRoute(
                name: "ImageDisplay",
                url: "ImageDisplay/{url}",
                defaults: new { controller = "Home", action = "Image", url = UrlParameter.Optional }
            );

            //routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    routeTemplate: "api/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);

            routes.MapRoute(
                name: "ImagesLarge",
                url: "Images/Large/{name}_{id}_{number}.{jpg}",
                defaults: new { controller = "Images", action = "Large", id = UrlParameter.Optional, number = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "HtmlProductWithCategory2",
                url: "urun/{url}-{id}-{CategoryId}.htm",
                defaults: new { controller = "Product", action = "Index", id = UrlParameter.Optional, CategoryId = UrlParameter.Optional, goNewUrl = "" }
            );

            routes.MapRoute(
                //eski yapı
                name: "HtmlProductWithCategory",
                url: "{url}_{id}-{CategoryId}.htm",
                defaults: new { controller = "Product", action = "Index", id = UrlParameter.Optional, CategoryId = UrlParameter.Optional, goNewUrl = "/urun" }
            );

            routes.MapRoute(
                name: "HtmlProduct2",
                url: "urun/{url}-{id}.html",
                defaults: new { controller = "Product", action = "Index", id = UrlParameter.Optional, goNewUrl = "" }
            );

            routes.MapRoute(
                //eski yapı
                name: "HtmlProduct",
                url: "{url}_{id}.htm",
                defaults: new { controller = "Product", action = "Index", id = UrlParameter.Optional, goNewUrl = "/urun" }
            );

            routes.MapRoute(
                name: "HtmlCategory2",
                url: "kategori/{url}_{id}.html",
                defaults: new { controller = "Categories", action = "Index", id = UrlParameter.Optional, goNewUrl = "" }
            );

            routes.MapRoute(
                //eski yapı
                name: "HtmlCategory",
                url: "{url}_{id}.html",
                defaults: new { controller = "Categories", action = "Index", id = UrlParameter.Optional, goNewUrl = "/kategori" }
            );

            routes.MapRoute(
                name: "HtmlCategoryWithCategoryFolder",
                url: "Kategori/{url}-{id}.html",
                defaults: new { controller = "Categories", action = "Index", id = UrlParameter.Optional, goNewUrl = "" }
            );

            routes.MapRoute(
                name: "HtmlProductsFull",
                url: "urunlerfull/{url}-{id}.html",
                defaults: new { controller = "Products", action = "IndexFull", id = UrlParameter.Optional, page = UrlParameter.Optional, goNewUrl = "" }
            );

            routes.MapRoute(
                name: "ProductsFullWithBrand",
                url: "ProductsFull/Index/{id}/{brand}",
                defaults: new { controller = "Products", action = "IndexFull", id = UrlParameter.Optional, page = UrlParameter.Optional, goNewUrl = "", brand = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "HtmlProducts2",
                url: "urunler/{url}-{id}.html",
                defaults: new { controller = "Products", action = "Index", id = UrlParameter.Optional, page = UrlParameter.Optional, goNewUrl = "" }
            );

            routes.MapRoute(
                name: "HtmlPackagesFull",
                url: "paket/{url}-{id}.html",
                defaults: new { controller = "Products", action = "PackagesIndex", id = UrlParameter.Optional, page = UrlParameter.Optional, goNewUrl = "" }
            );

            routes.MapRoute(
                //eski yapı
                name: "HtmlProducts",
                url: "{url}-{id}.html",
                defaults: new { controller = "Products", action = "Index", id = UrlParameter.Optional, page = UrlParameter.Optional, goNewUrl = "/urunler" }
            );

            routes.MapRoute(
                name: "BestSellerIndex",
                url: "BestSeller.html",
                defaults: new { controller = "Products", action = "BestSellerIndex", page = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "NewProductsIndex",
                url: "NewProducts.html",
                defaults: new { controller = "Products", action = "NewProductsIndex", page = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "CampaignsIndex",
                url: "Campaigns.html",
                defaults: new { controller = "Products", action = "CampaignsIndex", page = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "BasicIndex",
                url: "ProductFrame/{id}-{categoryid}.html",
                defaults: new { controller = "Product", action = "BasicIndex", id = UrlParameter.Optional, CategoryId = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "ProductEdit",
                url: "ProductManage/Edit/{id}",
                defaults: new { controller = "ProductManage", action = "Edit", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "AddProductToCategory",
                url: "Products/AddProductToCategory/{CategoryId}",
                defaults: new { controller = "Products", action = "AddProductToCategory", CategoryId = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "RemoveFromCategory",
                url: "Products/RemoveFromCategory/{CategoryId}/{ProductId}",
                defaults: new { controller = "Products", action = "RemoveFromCategory", CategoryId = UrlParameter.Optional, ProductId = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "PagesEdit",
                url: "Pages/Edit/{pageId}",
                defaults: new { controller = "Pages", action = "Edit", pageId = UrlParameter.Optional }
            );

            //routes.MapRoute(
            //    name: "Products",
            //    url: "Products/{category}/{id}",
            //    defaults: new { controller = "Products", action = "Index", id = UrlParameter.Optional }
            //);

            //routes.MapRoute(
            //    name: "Product",
            //    url: "Product/{name}/{id}",
            //    defaults: new { controller = "Product", action = "Index", id = UrlParameter.Optional }
            //);

            routes.MapRoute(
                name: "Pages2",
                url: "icerik/{pageName}",
                defaults: new { controller = "Pages", action = "Index", pageName = UrlParameter.Optional }
            );

            routes.MapRoute(
                //eski yapı
                name: "Pages",
                url: "Content/{pageName}",
                defaults: new { controller = "Pages", action = "Index", pageName = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Slider",
                url: "Slider/{pageName}",
                defaults: new { controller = "Slider", action = "Index", pageName = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "OdemeYap",
                url: "OdemeYap",
                defaults: new { controller = "Cart", action = "CheckOutCustom" }
            );

            routes.MapRoute(
                name: "CVGonder",
                url: "CV",
                defaults: new { controller = "ContactUs", action = "CVIndex" }
            );

            routes.MapRoute(
                name: "ProductsWithBrand",
                url: "Products/Index/{id}/{brand}",
                defaults: new { controller = "Products", action = "Index", id = UrlParameter.Optional, brand = UrlParameter.Optional }
            );
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}